'use strict';
app.service('modulesAdvertisementEditService',['$q','utilService',function($q,utilService){
    var _this_=this;
    _this_.modulesAdvertiseEditVO={};

    //查询广告分类下拉框
    _this_.getList = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'advertise/type/list'
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错");
        });
        return deferred.promise;
    }

    //查询ById
    _this_.findById = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'advertise/'+ $scope.advertise.id,
            params:{id:$scope.advertise.id}
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错");
        });
        return deferred.promise;
    }


    //删除模块广告图片
    _this_.delImages= function ($scope,id) {

        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'advertise/pic',
            data:{id:id},
            method:'DELETE'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }


    //修改广告
    this.editAdvertise = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'advertise',
            data:$scope.advertise,
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }




}]);